<?php
class ZthbhkenhsController extends AppController {

	var $name = 'Zthbhkenhs';

	function index() {
		$this->Zthbhkenh->recursive = 0;
		$this->set('zthbhkenhs', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid zthbhkenh', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('zthbhkenh', $this->Zthbhkenh->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Zthbhkenh->create();
			if ($this->Zthbhkenh->save($this->data)) {
				$this->Session->setFlash(__('The zthbhkenh has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The zthbhkenh could not be saved. Please, try again.', true));
			}
		}
		$nhanviens = $this->Zthbhkenh->Nhanvien->find('list');
		$kenhs = $this->Zthbhkenh->Kenh->find('list');
		$hanghoas = $this->Zthbhkenh->Hanghoa->find('list');
		$this->set(compact('nhanviens', 'kenhs', 'hanghoas'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid zthbhkenh', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Zthbhkenh->save($this->data)) {
				$this->Session->setFlash(__('The zthbhkenh has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The zthbhkenh could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Zthbhkenh->read(null, $id);
		}
		$nhanviens = $this->Zthbhkenh->Nhanvien->find('list');
		$kenhs = $this->Zthbhkenh->Kenh->find('list');
		$hanghoas = $this->Zthbhkenh->Hanghoa->find('list');
		$this->set(compact('nhanviens', 'kenhs', 'hanghoas'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for zthbhkenh', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Zthbhkenh->delete($id)) {
			$this->Session->setFlash(__('Zthbhkenh deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Zthbhkenh was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}

	//function 
	
}
